/*
 * Copyright (C), 2002-2013, 苏宁易购电子商务有限公司
 * FileName: ConverterFactoryBean.java
 * Author:   12070644@cnsuning.com
 * Date:     2013-9-27 上午00:00:00
 */
package com.suning.sawp.service.mongodb;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.data.mongodb.core.convert.DefaultMongoTypeMapper;
import org.springframework.data.mongodb.core.convert.MappingMongoConverter;
import org.springframework.data.mongodb.core.convert.MongoTypeMapper;

/**
 * Mongodb转化类
 * 〈一句话功能简述〉<br> 
 * 〈功能详细描述〉
 *
 * @author 12070644@cnsuning.com
 * @see [相关类/方法]（可选）
 * @since [产品/模块版本] （可选）
 */
public class ConverterFactoryBean implements FactoryBean<MappingMongoConverter> {
    /**
     * MappingMongoConverter
     */
    private MappingMongoConverter converter;

    /**
     * setConverter
     * 
     * @param converter
     */
    public void setConverter(MappingMongoConverter converter) {
        this.converter = converter;
    }

    /**
     * MappingMongoConverter
     */
    public MappingMongoConverter getObject() throws Exception {
        MongoTypeMapper typeMapper = new DefaultMongoTypeMapper(null);
        converter.setTypeMapper(typeMapper);
        return converter;
    }

    /**
     * getObjectType
     */
    public Class<?> getObjectType() {
        return MappingMongoConverter.class;
    }

    /**
     * isSingleton
     */
    public boolean isSingleton() {
        return true;
    }

}